#include"CSemaphore.h"
CSemaphore::CSemaphore(long count)
	:m_count(count)
{
}

void CSemaphore::Signal()
{
	std::unique_lock<std::mutex> lock(_mutex);
	++m_count;
	_cv.notify_one();
}

void CSemaphore::Wait()
{
	std::unique_lock<std::mutex> lock(_mutex);
	_cv.wait(lock, [=] {return m_count > 0; });
	--m_count;
}